<%--
  Created by IntelliJ IDEA.
  User: ccvv
  Date: 2021/4/23
  Time: 17:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath()+"/"; %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head lang="en">
    <base href="<%=path%>">
    <meta charset="UTF-8">
    <title>注册</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="stylesheet" href="layui/AmazeUI-2.4.2/assets/css/amazeui.css" />
    <link href="layui/css/dlstyle.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" href="layui/css/font.css">
    <link rel="stylesheet" href="layui/css/xadmin.css">
    <script type="text/javascript" src="layui/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="layui/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

<div class="login-banner">
    <div class="login-main">
        <div class="layui-fluid" >
            <div class="layui-row" >
                <form class="layui-form" style="float: right;margin-top:120px;margin-right:17%" id="form1">
                    <!--<div class="layui-form-item">
                        <label for="username" class="layui-form-label" style="width: 130px">
                            <span class="x-red">*</span>企业名称
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="username" name="username" value="山西软赢科技" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>-->
                    <input type="hidden" name="companyName" value="${company.companyName}">
                    <input type="hidden" name="email" value="${company.email}">
                    <input type="hidden" name="person" value="${company.person}">
                    <input type="hidden" name="password" value="${company.password}">
                    <input type="hidden" name="invitecode" value="${company.invitecode}">

                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: 130px">
                            <span class="x-red">*</span>所属行业
                        </label>
                        <div class="layui-input-inline">
                            <select name="industry" lay-verify="required">
                                <option value="">选择企业所属行业</option>
                                <c:forEach items="${dIposeconds}" var="dIposecond">
                                    <option value="${dIposecond.secondCode}">${dIposecond.secondName}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label" style="width: 130px">
                            <span class="x-red">*</span>企业类型
                        </label>
                        <div class="layui-input-inline">
                            <select name="type" lay-verify="required">
                                <option value="">选择企业类型</option>
                                <option value="1">有限责任公司</option>
                                <option value="2">股份有限公司</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label" style="width: 130px">
                            <span class="x-red">*</span>所在地
                        </label>
                        <div class="layui-input-inline">
                            <select name="province" lay-verify="required" lay-filter="province" id="province">
                                <option value="">选择省份</option>
                                <c:forEach items="${bProvinces}" var="bProvince">
                                    <option value="${bProvince.provinceId}">${bProvince.province}</option>
                                </c:forEach>
                            </select>
                            <select name="city" lay-verify="required" id="city" lay-filter="city">

                            </select>
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label" style="width: 130px">
                            <span class="x-red">*</span>详细地址
                        </label>
                        <div class="layui-input-inline" >
                            <input type="text" id="address" name="address"
                                   autocomplete="off" class="layui-input" lay-verify="required">
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label" style="width: 130px">
                            <!-- <span class="x-red">*</span>-->企业网址
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_email" name="website"
                                   autocomplete="off" class="layui-input" lay-verify="url">
                        </div>
                    </div>
                    <input type="hidden" value="0" name="flag">
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label" style="width: 130px">

                        </label>
                        <div class="layui-input-inline">
                            <button  class="layui-btn" lay-filter="add" lay-submit="">
                                注册
                            </button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
        <!-- <div class="login-links">
             <label for="remember-me"><input id="remember-me" type="checkbox">记住密码</label>
             <a href="#" class="am-fr">忘记密码</a>
               <a href="register.html" class="zcnext am-fr am-btn-default">注册</a>
             <br />
         </div>
         <div class="am-cf">
             <a href="./index1.html"><input type="submit" name="" value="登 录" class="am-btn am-btn-primary am-btn-sm"></a>
         </div>-->

    </div>
</div>
</div>


<script>
    layui.use(['form', 'layer'],function() {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        form.on('select(province)',function (data){
            $("#city").empty();
            var provinceId = $("#province").val();
            $.get('queryCity?provinceId='+provinceId,function (ret) {

                $("#city").append(
                    "<option value=''>"+"选择城市"+"</option>"
                )
                for(let i = 0; i < ret.length; i ++){
                    $("#city").append(
                        "<option value='"+ret[i].cityId+"'>"+ret[i].city+"</option>"
                    )
                }
                form.render();
            })

        });

        //监听提交
        form.on('submit(add)',
            function(data) {
                /*var len = $("#form1")[0].elements.length;
                for (let i = 6; i < len-2; i ++){
                    if(i == 7 || i == 9 || i == 11){
                        continue;
                    }
                    if($("#form1")[0].elements[i].value == ""){
                        return false;
                    }
                }*/

                //发异步，把数据提交给php
                var company = $("#form1").serialize()+"&registertime="+new Date().toLocaleString();
                $.ajax({
                    url:'register',
                    dataType:'json',
                    type:'post',
                    data:company,
                    success:function (ret) {
                        if(ret.status){
                            layer.alert("注册成功,请等待管理员审核", {
                                icon: 6
                            },
                            function() {
                                //关闭当前frame
                                window.location.href='login.jsp';
                            });
                        }else {
                            layer.msg("操作失败");
                        }
                    }
                })
                return false;
            });

    });
</script>
<%--<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>--%>
</body>

</html>
